/* RPC client for simple addition example */


#include <iostream>
#include <stdio.h> 
#include "BIC.h" 


/* Wrapper function takes care of calling the RPC procedure */

int add( CLIENT *clnt, int x) {
  int *result;

  /* Call the client stub created by rpcgen */
  result = add_1(&x,clnt);
  if (result == NULL) {
    cout << "error" << endl;
    return -1;
  }
  return *result;
}
float fadd( CLIENT *clnt, float x) {
  float *result;

  /* Call the client stub created by rpcgen */
  result = fadd_2(&x,clnt);
  if (result == NULL) {
    cout << "error" << endl;
    return -1;
  }
  return *result;
}

char chartest( CLIENT *clnt, char x) {
  char *result;

  /* Call the client stub created by rpcgen */
  result = chartest_3(&x,clnt);
  if (result == NULL) {
    cout << "error" << endl;
    return -1;
  }
  return *result;
}

int main( int argc, char *argv[]) {
   CLIENT *clnt = NULL;
   clnt = my_clnt_create(SIMP_PROG);
   int x = 100;
   float y = 111.0;
   char z = 'A';
  if (clnt == (CLIENT *) NULL){
      cout << "Can not create CLIENT " << endl;
      //exit(1);
  }
  else
  {
    cout << "Hello world, this my test" << endl;
    cout << "test result is : "  << endl
         <<"    int test: 100 + 100 = " << add(clnt,x) << endl
         <<"    float test:111.0 + 1.1 = "<< fadd(clnt,y) << endl
         <<"    char test: should return a, result: " << chartest(clnt,z) << endl;
    delete clnt;
    clnt = NULL;
  }
   
  return(0);
}



